package com.xx.job.controller.system;


import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysDictData;
import com.xx.job.entity.system.SysDictType;
import com.xx.job.service.system.SysDictDataService;
import com.xx.job.service.system.SysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1/dict")
public class SysDictDataController extends BaseController {
    @Autowired
    private SysDictDataService sysDictDataService;

    @RequestMapping("/databytype/{dictType}")
    public Result sysUserSex(@PathVariable String dictType){
        return Result.success(sysDictDataService.dictData(dictType));
    }

    @GetMapping("/datalist")
    public Result datalist(PageDTO pageDTO, SysDictData sysDictData){
        return Result.success(sysDictDataService.selectPage(pageDTO,sysDictData));
    }

    @PostMapping("/data")
    public Result addData(@RequestBody SysDictData sysDictData){
        return Result.success(sysDictDataService.add(sysDictData));
    }

    @DeleteMapping("/data/{id}")
    public Result deleteData(@PathVariable Long id){
        return Result.success(sysDictDataService.delete(id));
    }

    @GetMapping("/data/{id}")
    public Result selectData(@PathVariable Long id){
        return Result.success(sysDictDataService.select(id));
    }

    @PutMapping("/data")
    public Result updateData(@RequestBody SysDictData sysDictData){
        return Result.success(sysDictDataService.update(sysDictData));
    }

}

